*Last updated:* 2025-08-15

*Purpose:* This repository contains the replication materials the article:
Riaz, Sascha and Hamjediers, Maik: "Anti-Immigrant Bias in the Choice Between Punitive and 
Rehabilitative Justice", to be published in British Journal of Political Science


*Contact:* For questions or suggestions, please contact Maik Hamjediers at maik.hamjediers@eui.eu


## 1. Directory Structure 

The replication files assume the following directory structure:

```
├── External_data
│   ├── 0_citizenship_residential_permits.do
│   ├── 0_migration_bycitizenship.do
│   ├── 0_migration+tourists_bydistrict.do
│   ├── citizenships_residentialpermits.xlsx
│   ├── District_IDs.xlsx
│   ├── election_2017_results_counties
│   ├── FDZ_country_codes.xlsx
│   ├── foreigners_bycitizenship.xlsx
│   ├── iso_codes_to_regions.xlsx
│   ├── issue_salience.xlsx
│   ├── merge_county_district.dta
│   ├── migration_bycitizenship.xlsx
│   ├── migration_bycounty.xlsx
│   ├── nationality_coding_as_TableA2.txt
│   ├── population_bycounty2009.xlsx
│   ├── population_bycounty2011.xlsx
│   ├── schutzsuchende_bysex.xlsx
│   ├── tourism_bycounty.xlsx
│ 	 └── shapefiles
│      ├── 0_district_county_conv.R
│      ├── border_counties.xlsx
│      ├── county_to_district.rds
│      ├── border_districts.xlsx
│      ├── judicialdistricts
│      └── counties
├── FDZ_externaldata
│   ├── 1_migration_bycitizenship.dta
│   └── 2_migration_tourists_bycounty.dta
├── FDZ_ado
│   └── ...
├── FDZ_script.do
├── FDZ_results
│   ├── table_1.xlsx - table_A15.xlsx
│   ├── figure_1.xlsx - figure_A6.xlsx
│   ├── figure_1.tiff
│   └── figure_A3.pdf - figure_A7b.pdf
├── figures.do
└── figures.R
```


## 2. Folder and File Descriptions 

### Scripts prior to the main analyses
External data used to construct measures and variables for the remote data processing.

* `0_citizenship_residential_permits.do`
	* Purpose: List country-codes for analysis in Table A.13 and used in `FDZ_script.do`
* `0_migration_bycitizenship.do`
	* Purpose: Generate dataset `1_migration_bycitizenship.dta` in `FDZ_externaldata`
* `0_migration+tourists_bydistrict.do`
	* Purpose: Generate dataset `2_migration_tourists_bycounty.dta` in `FDZ_externaldata`
* `shapefiles/0_district_county_conv.R`
	* Purpose: Generate conversion of counties to judicial districts (saved as `county_to_district.rds`) and identify bordering districts used in `FDZ_script.do` 
*all other files are external data, obtained from various sources (see Supplementary Files of the paper)


### Files to be uploaded to the remote data processing
 
* FDZ_externaldata
	* Purpose: External data from `0_migration_bycitizenship.do` and `0_migration+tourists_bydistrict.do` 
* FDZ_ado
	* Purpose: User written commands that are used by `1_FDZ_script.do`
* `FDZ_script.do`
	* Purpose: Actual analysis script containing all analyses
* FDZ_results (content to be received from the remote data processing)
	* Purpose: Folder for all estimates produced by `FDZ_script.do`
	* Note: Contains currently all approved files from the last remote data processing

### Post-estimation scripts 
To create figures from estimates received after the remote data processing.

* `figures.do`
	* Purpose: Produce Figure A.3, Figure A.4b, Figure A.5a, and Figure A.5b based on estimates in `FDZ_results`
* `figures.R`
	* Purpose: Produce Figure 1 and Figure A.4a


## 3. Replication instructions 

To replicate the data processing steps before conducting the remote data processing for the main analyses, you can run the scripts described under the heading **Scripts prior to the main analyses**. However, this step is optional, as the prepared data required for the replication is already included in this package. If you choose to run these scripts, you may need to adjust the working directories.

To replicate the actual estimates for the main paper and the appendix, you will need access to controlled remote data processing for the "Strafverfolgungsstatistik" from the German Federal Statistical Office. After signing a data agreement and the "procedural description for merging data materials," send the folders `FDZ_externaldata' and `FDZ_ado' as well as the script `FDZ_script.do' (adjust the directory paths according to your project agreement) to the Research Data Center (FDZ). Once FDZ grants approval for data protection, the processed output should be stored in the `FDZ_results' folder.

The approved results from the latest execution can be found in the `FDZ_results' folder of this replication package.
All the tables for the main paper and appendix can be found here. 
To generate all the figures for the main paper and appendix, run figures.R' ànd `figures.do' (make sure to adjust the working directories as needed). These scripts should be executed based on the estimates in `FDZ_results' (either from the Dataverse or from newly received output from remote data processing). All figures will be saved in the `FDZ_results' folder.


## 4. Software details 

This replication package has been tested locally on the following
operating system, Stata and R versions:
* Windows 11 Home 24H2 
* StataNow 18.5 SE, 18 
* R 4.3.1 (2023-06-16 ucrt)

We recommend the following versions of R packages to ensure consistent results :
* tidyverse	2.0.0	
* dplyr	    1.1.4
* janitor	2.2.1
* readxl	1.4.5	
* writexl 	1.5.4	
* scales	1.1.4
* sf		1.0.21
* ggplot2	3.5.2


